Last updated: 2023-07-31
Checks: 5 1
Knit directory: WenjunLiu_Thesis_Chapter4/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200930) was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Tracking code development and connecting the code version to the
results is critical for reproducibility. To start using Git, open the
Terminal and type git init in your project directory.
This project is not being versioned with Git. To obtain the full
reproducibility benefits of using workflowr, please see
?wflow_start.
library(ngsReports)
library(tidyverse)
library(yaml)
library(scales)
library(pander)
library(glue)
library(plotly)
panderOptions("table.split.table", Inf)
panderOptions("big.mark", ",")
theme_set(theme_bw())
config <- here::here("config/config.yml") %>%
read_yaml()
suffix <- paste0(config$tag, config$ext)
sp <- config$ref$species %>%
str_replace("(^[a-z])[a-z]*_([a-z]+)", "\\1\\2") %>%
str_to_title()
samples <- config$samples %>%
here::here() %>%
read_tsv() %>%
mutate(
Filename = paste0(sample, suffix)
)
config$analysis <- config$analysis %>%
lapply(intersect, y = colnames(samples)) %>%
.[vapply(., length, integer(1)) > 0]
if (length(config$analysis)) {
samples <- samples %>%
unite(
col = group,
any_of(as.character(unlist(config$analysis))),
sep = "_", remove = FALSE
)
} else {
samples$group <- samples$Filename
}
group_cols <- hcl.colors(
n = length(unique(samples$group)),
palette = "Zissou 1"
) %>%
setNames(unique(samples$group))
rawFqc <- here::here("data/raw/FastQC") %>%
list.files(pattern = "zip", full.names = TRUE) %>%
FastqcDataList() %>%
.[fqName(.) %in% samples$Filename]
plotSummary(rawFqc) +
theme(axis.text.y=element_blank())
Overall summary of FastQC reports
A total of 792 libraries were contained in this dataset, with read totals ranging between 974,545 and 6,174,727 reads.
Across all libraries, reads were 40 bases.
plotReadTotals(rawFqc, pattern = suffix) +
theme(axis.text.y=element_blank())
Library Sizes for all supplied fastq files. Any samples run as multiple libraries are shown as the supplied multiple libraries and have not been merged.
plotBaseQuals(
rawFqc,
pattern = suffix,
dendrogram = TRUE,
cluster = TRUE
) +
theme(axis.text.y=element_blank())
Mean sequencing quality scores at each base position for each library
plotGcContent(
x = rawFqc,
pattern = suffix,
species = sp,
gcType = "Trans",
usePlotly = TRUE,
dendrogram = TRUE,
cluster = TRUE
)
GC content shown as the % above and below the theoretical GC content for the Hsapiens transcriptome.
ggplotly(
getModule(rawFqc, "Per_sequence_GC_content") %>%
group_by(Filename) %>%
mutate(
cumulative = cumsum(Count) / sum(Count)
) %>%
ungroup() %>%
left_join(samples) %>%
bind_rows(
getGC(gcTheoretical, sp, "Trans") %>%
mutate_at(sp, cumsum) %>%
rename_all(
str_replace_all,
pattern = sp, replacement = "cumulative",
) %>%
mutate(
Filename = "Theoretical GC",
group = Filename
)
) %>%
mutate(
group = as.factor(group),
group = relevel(group, ref = "Theoretical GC"),
cumulative = round(cumulative*100, 2)
) %>%
ggplot(aes(GC_Content, cumulative, group = Filename)) +
geom_line(aes(colour = group), size = 1/3) +
scale_x_continuous(label = ngsReports:::.addPercent) +
scale_y_continuous(label = ngsReports:::.addPercent) +
scale_colour_manual(
values = c("#000000", group_cols)
) +
labs(
x = "GC Content",
y = "Cumulative Total",
colour = "Group"
)
)
GC content shown as a cumulative distribution for all libraries. Groups can be hidden by clicking on them in the legend.
plotly::ggplotly(
getModule(rawFqc, module = "Per_base_sequence_content") %>%
mutate(Base = fct_inorder(Base)) %>%
group_by(Base) %>%
mutate(
across(c("A", "C", "G", "T"), function(x){x - mean(x)})
) %>%
pivot_longer(
cols = c("A", "C", "G", "T"),
names_to = "Nuc",
values_to = "resid"
) %>%
left_join(samples) %>%
ggplot(
aes(Base, resid, group = Filename, colour = group)
) +
geom_line() +
facet_wrap(~Nuc) +
scale_colour_manual(values = group_cols) +
labs(
x = "Read Position", y = "Residual", colour = "Group"
)
)